package net.chenlin.dp.modules.base.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.common.utils.CommonUtils;
import net.chenlin.dp.modules.base.entity.SysWarehouseEntity;
import net.chenlin.dp.modules.base.manager.SysWarehouseManager;
import net.chenlin.dp.modules.base.service.SysWarehouseService;

/**
 * 仓库
 *
 * @author ZhouChenglin
 * @email yczclcn@163.com
 * @url www.chenlintech.com
 * @date 2018年12月03日 下午10:05:32
 */
@Service("sysWarehouseService")
public class SysWarehouseServiceImpl implements SysWarehouseService {

	@Autowired
	private SysWarehouseManager sysWarehouseManager;

	@Override
	public Page<SysWarehouseEntity> listSysWarehouse(Map<String, Object> params) {
		Query query = new Query(params);
		Page<SysWarehouseEntity> page = new Page<>(query);
		sysWarehouseManager.listSysWarehouse(page, query);
		return page;
	}

	@Override
	public R saveSysWarehouse(SysWarehouseEntity role) {
		int count = sysWarehouseManager.saveSysWarehouse(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getSysWarehouseById(Long id) {
		SysWarehouseEntity sysWarehouse = sysWarehouseManager.getSysWarehouseById(id);
		return CommonUtils.msg(sysWarehouse);
	}

	@Override
	public R updateSysWarehouse(SysWarehouseEntity sysWarehouse) {
		int count = sysWarehouseManager.updateSysWarehouse(sysWarehouse);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(Long[] id) {
		int count = sysWarehouseManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
